package org.wat.wcy.isi.mmazur.bp.io.model;

import java.io.IOException;
import java.io.RandomAccessFile;

import org.wat.wcy.isi.mmazur.bp.io.BinaryObject;

public class Coordinate extends BinaryObject {

	private int x, y;

	public Coordinate() {
		x = -1;
		y = -1;
	}

	public int getX() {
		return x;
	}

	public void setX(int x) {
		this.x = x;
	}

	public int getY() {
		return y;
	}

	public void setY(int y) {
		this.y = y;
	}

	@Override
	public void write(RandomAccessFile raf) {
		try {
			raf.writeInt(x);
			raf.writeInt(y);
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	@Override
	public void read(RandomAccessFile raf) {
		try {
			x = raf.readInt();
			y = raf.readInt();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
	
	public static int sizeOf() {
		  return (int) (Integer.SIZE / 8) * 2;
	  }

	public boolean isNotNull() {
		return !isNull();
	}

	private boolean isNull() {
		return x == -1 && y == -1;
	}

}
